#pragma once
#include "StdAfx.h"

class CursorTraceRenderer : public IVisCallbackHandler_cl, public VRefCounter
{
public:
	CursorTraceRenderer();
	~CursorTraceRenderer();

	void OnHandleCallback(IVisCallbackDataObject_cl *pData);

	void ToggleEnable(bool enable,hkvVec2 cursorPos = hkvVec2(0,0));

	void Update(hkvVec2 cursorPos);

protected:

	void Reset();

	void UpdateCurrentTrailPiece(hkvVec2 cursorPos);

	void UpdateAllTrailPieces();

protected:
	bool m_bEnable;
	float m_maxLen;
	float m_lineWidth;
	float m_curLen;
	float m_lastDiffLen;
	VArray<Overlay2DVertex_t> m_vertices;

	struct TrailPiece
	{
		hkvVec2 m_startPos;
		hkvVec2 m_endPos;
		float m_length;
	};

	VArray<TrailPiece> m_trailPieces;

	hkvVec2 m_cursorPos;
	hkvVec2 m_prevcursorPos;
	hkvVec2 m_moveDir;

	VSmartPtr<VTextureObject> m_spTrailTex;
};
